<?php
/**
 * Created by PhpStorm.
 * User: cls
 * Date: 2018/4/17
 * Time: 18:42
 */

namespace Biz\module\Behaviors;

use Biz\pockets\constInterface\ActivityInfo;
use Biz\module\Behaviors\Activity\FullShipping as BFullShipping;

class ActivityBehavior
{

    const model_map = [
        ActivityInfo::ACTIVITY_TYPE_FULL_SHIPPING => BFullShipping::class
    ];


    public static function add($uid, $type, $fields)
    {
        $call_method = [
            self::model_map[$type],
            __FUNCTION__
        ];

        return call_user_func_array($call_method, [$uid, $fields]);
    }

    public static function ActivityList($type_id, $uid)
    {
        $call_method = [
            self::model_map[$type_id],
            __FUNCTION__
        ];

        return call_user_func_array($call_method, [$uid]);

    }

    public static function EditActivitys($type_id, $uid, $id, $fields)
    {

        $call_method = [
            self::model_map[$type_id],
            __FUNCTION__
        ];

        return call_user_func_array($call_method, [
            $uid,
            $id,
            $fields
        ]);

    }


    public static function Info($uid, $id, $type_id)
    {
        $infos = call_user_func_array([
            self::model_map[$type_id],
            'ActivityList'
        ], [
            $uid
        ]);
        $infos = array_column($infos, null, 'id');
        if (isset($infos[$id])) {
            return $infos[$id];
        }

        return [];

    }

    public static function changeStatus($shop_id, $id, $type_id)
    {
        return call_user_func_array([
            self::model_map[$type_id],
            __FUNCTION__
        ], [
            $shop_id,
            $id
        ]);
    }


}